//
//  PersonInfoViewController.swift
//  SidebarMenu
//
//  Created by LiangXiaobin on 2017/1/24.
//  Copyright © 2017年 AppCoda. All rights reserved.
//

import UIKit

class PersonInfoViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,UITextViewDelegate {

    var tableView:UITableView?
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        self.topTittle?.text = "个人资料"
        
        tableView = UITableView(frame:CGRect(x:0,y:64,width:screenWidth,height:screenHeight - 64))
        tableView?.backgroundColor = UIColor.white
        tableView?.delegate = self
        tableView?.dataSource = self
        tableView?.separatorStyle = .none
        tableView?.register(PersonInfoTableViewCell.self, forCellReuseIdentifier: "PersonInfoTableViewCell")
        self.view.addSubview(tableView!)
        
        
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 5
    }
    
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        
        let cellIdentifier = "PersonInfoTableViewCell"
        
        var cell:PersonInfoTableViewCell? = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) as? PersonInfoTableViewCell
        if !(cell != nil) {
            cell = PersonInfoTableViewCell(style:.default, reuseIdentifier:cellIdentifier)
        }
        if(indexPath.row == 0 || indexPath.row == 4) {
            
        }
        else
        {
            
        }
        
        return cell!
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        
        return 40
    }
    
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        
        return 60
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        
        return 108
    }
    
    
    
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        
        let view = UIView(frame:CGRect(x:0,y:0,width:screenWidth,height:60))
        let headImage = UIImageView(frame:CGRect(x:14,y:0,width:50,height:50))
        headImage.layer.cornerRadius = 25
        view.addSubview(headImage)
        
        let leftBtn = UIButton(type:.system)
        leftBtn.frame = CGRect(x:screenWidth - 60,y:0,width:40,height:60)
        leftBtn.setTitle("点击更换", for: .normal)
        view.addSubview(leftBtn)
        
        
        return view
        
    }
    
    
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let view = UIView(frame:CGRect(x:0,y:0,width:screenWidth,height:108))
        
        let headLabel = UILabel(frame:CGRect(x:14,y:0,width:80,height:40))
        headLabel.textAlignment = NSTextAlignment.left
        headLabel.text = "简      介"
        view.addSubview(headLabel)

        
        let detailTextView = UITextView(frame:CGRect(x:14,y:40,width:screenWidth - 28,height:108 - 40))
        detailTextView.text = "XXXXXX"

        detailTextView.tag = 33
        detailTextView.delegate = self
        view.addSubview(detailTextView)
        
        return view
    }
    
    
    func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
        
        return true
    }
    
    func textViewDidBeginEditing(_ textView: UITextView) {
        
    }

    

    
    
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
